<?php
set_time_limit(0);
error_reporting(E_ALL ^ E_NOTICE);
date_default_timezone_set("PRC");
header('Content-type: text/html; charset=utf-8');
require 'frame/eFrame.php';
class main {
	public $controllerPath;
	public $method;
	public $module;
	public $controller;
	public function init() {
		$requestedUri = $_SERVER["REQUEST_URI"];
		$requestedUri = preg_replace("/\/{2,}/i", "/", $requestedUri);
		if (false !== ($getPosition = strpos($requestedUri, '?'))) {
			$requestedUri = substr($requestedUri, 0, $getPosition);
		}
		$defaut = "/reception/index/";
		$requestedUri = empty($requestedUri) || $requestedUri == "/" ? $defaut : $requestedUri;
		if (substr($requestedUri, -1, 1) != "/") {
			$requestedUri .= "/";
		}
		list($emptyelem, $module, $controller, $method) = explode("/", $requestedUri);
		$this->method = $method ?: "main";
		$this->controllerPath = $module.DS."c".DS.$controller.".php";
		$this->module = $method;
		$this->controller = $controller;
	}
	
	public function run() {
		$croot = WEBSITE.$this->controllerPath;
		$controller = $this->controller;
		$method  = $this->method;
		if (file_exists($croot)) {
			require $croot;
			$c = new $controller();
			if (!method_exists($c, $method)) {
				$this->error();
			} else {
				$c->$method();
			}
			
		} else {
			$this->error();
		}
	}
	
	public function error() {
		
		echo "访问错误!";
	}
}
$excute = new main();
$excute->init();
$excute->run();
?>